﻿using System.Windows;
using System.Windows.Controls;
using corpus_platform.ViewModels;

namespace corpus_platform.Views
{

    public class FrameElementTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            FrameworkElement element = (FrameworkElement)container;
            INodeFrameElement frameElement = (INodeFrameElement)item;
            if (frameElement != null && element != null)
            {
                switch (frameElement.Type)
                {
                    case Data.FrameElementType.Boolean:
                        return (DataTemplate)element.FindResource("BooleanTemplate");
                    case Data.FrameElementType.String:
                        return (DataTemplate)element.FindResource("StringTemplate");
                    case Data.FrameElementType.Single:
                        return (DataTemplate)element.FindResource("SingleTemplate");
                    case Data.FrameElementType.Multiple:
                        return (DataTemplate)element.FindResource("MultipleTemplate");
                    default:
                        return null;
                }
            }
            return null;
        }
    }

    public class StructureTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            FrameworkElement element = (FrameworkElement)container;
            INodeStructure structure = (INodeStructure)item;
            if (structure != null && element != null)
            {
                switch (structure.Type)
                {
                    case StructureType.Frame:
                        return (DataTemplate)element.FindResource("FrameTemplate");
                    case StructureType.Ontology:
                        return (DataTemplate)element.FindResource("OntologyTemplate");
                    case StructureType.Root:
                        break;
                    default:
                        break;
                }
            }
            return null;
        }
    }
}